Servicing Other Threads
When you are running a Macintosh embedding application, you must explicitly tell JManager to give up time to the Java virtual machine. You do so by using theJMIdle
function (page 57) in your main event loop. Listing 1-2 shows an example of usingJMIdle
.Listing 1-2 Using the
JMIdle
function
Boolean MainEventLoopContinues = true; while (MainEventLoopContinues) { EventRecord eve; if (! WaitNextEvent(everyEvent, &eve, 30, nil) || eve.what == nullEvent) JMIdle(theSession, 100); else handleEvent(&eve); }The value specified inJMIdle
indicates how many milliseconds to allot to other threads.JMIdle
returns immediately if no threads need servicing.JMIdle
also returns if a user event occurs in the current session.